<?php
namespace Plugin\Alarm\Schema;

use Plugin\Alarm\Model\RdAlarmMsg;
use Hyperf\Swagger\Annotation\Property;
use Hyperf\Swagger\Annotation\Schema;

/**
 * 报警事件回调
 */
#[Schema(title: 'RdAlarmMsgSchema')]
class RdAlarmMsgSchema implements \JsonSerializable
{
    #[Property(property: 'id', title: 'id', type: 'bigint')]
    public string $id;

    #[Property(property: 'type', title: '报警类型1:雷达 2:相机', type: 'int')]
    public string $type;

    #[Property(property: 'alarm_pic_path', title: '报警图片地址', type: 'string')]
    public string $alarm_pic_path;

    #[Property(property: 'alarm_pic_name', title: '报警图片名称', type: 'string')]
    public string $alarm_pic_name;

    #[Property(property: 'camera_id', title: '摄像头ID', type: 'int')]
    public string $camera_id;

    #[Property(property: 'camera_url', title: '摄像头地址', type: 'string')]
    public string $camera_url;

    #[Property(property: 'image_height', title: '图片高度', type: 'int')]
    public string $image_height;

    #[Property(property: 'image_width', title: '图片宽度', type: 'int')]
    public string $image_width;

    #[Property(property: 'result_data', title: '检测结果数据', type: 'array')]
    public array $result_data;

    #[Property(property: 'roi', title: '感兴趣区域', type: 'array', nullable: true)]
    public ?array $roi;

    #[Property(property: 'src_pic_path', title: '源图片地址', type: 'string')]
    public string $src_pic_path;

    #[Property(property: 'src_pic_name', title: '源图片名称', type: 'string')]
    public string $src_pic_name;

    #[Property(property: 'task_id', title: '任务ID', type: 'bigint')]
    public string $task_id;

    #[Property(property: 'timestamp', title: '时间戳', type: 'bigint')]
    public string $timestamp;

    #[Property(property: 'yj_data_id', title: '预警ID', type: 'string')]
    public string $yj_data_id;

    #[Property(property: 'device_serial', title: '设备序列号', type: 'string')]
    public string $device_serial;

    #[Property(property: 'channel_no', title: '通道号', type: 'int')]
    public string $channel_no;

    #[Property(property: 'msg_type', title: '消息类型', type: 'string')]
    public string $msg_type;

    #[Property(property: 'alarm_type', title: '报警类型', type: 'int')]
    public string $alarm_type;

    #[Property(property: 'file_url', title: '文件地址', type: 'string')]
    public string $file_url;

    #[Property(property: 'created_at', title: '创建时间', type: 'timestamp')]
    public string $created_at;

    #[Property(property: 'updated_at', title: '更新时间', type: 'timestamp')]
    public string $updated_at;




    public function __construct(RdAlarmMsg $model)
    {
       $this->id = $model->id;
       $this->type = $model->type;
       $this->alarm_pic_path = $model->alarm_pic_path;
       $this->alarm_pic_name = $model->alarm_pic_name;
       $this->camera_id = $model->camera_id;
       $this->camera_url = $model->camera_url;
       $this->image_height = $model->image_height;
       $this->image_width = $model->image_width;
       $this->result_data = $model->result_data;
       $this->roi = $model->roi;
       $this->src_pic_path = $model->src_pic_path;
       $this->src_pic_name = $model->src_pic_name;
       $this->task_id = $model->task_id;
       $this->timestamp = $model->timestamp;
       $this->yj_data_id = $model->yj_data_id;
       $this->device_serial = $model->device_serial;
       $this->channel_no = $model->channel_no;
       $this->msg_type = $model->msg_type;
       $this->alarm_type = $model->alarm_type;
       $this->file_url = $model->file_url;
       $this->created_at = $model->created_at;
       $this->updated_at = $model->updated_at;

    }

    public function jsonSerialize(): array
    {
        return [
            'id' => $this->id,
            'type' => $this->type,
            'alarm_pic_path' => $this->alarm_pic_path,
            'alarm_pic_name' => $this->alarm_pic_name,
            'camera_id' => $this->camera_id,
            'camera_url' => $this->camera_url,
            'image_height' => $this->image_height,
            'image_width' => $this->image_width,
            'result_data' => $this->result_data,
            'roi' => $this->roi,
            'src_pic_path' => $this->src_pic_path,
            'src_pic_name' => $this->src_pic_name,
            'task_id' => $this->task_id,
            'timestamp' => $this->timestamp,
            'yj_data_id' => $this->yj_data_id,
            'device_serial' => $this->device_serial,
            'channel_no' => $this->channel_no,
            'msg_type' => $this->msg_type,
            'alarm_type' => $this->alarm_type,
            'file_url' => $this->file_url,
            'created_at' => $this->created_at,
            'updated_at' => $this->updated_at
        ];
    }
}